Welcome![Sign In][Sign Up]
Location:
Search - INT 1

Search list

[Mathimatics-Numerical algorithms遗传算法SGA

Description: 包含一个cpp文件,含有main()函数! 主要函数如下 void InitData(); int Flip(float probabiliby); float Random(); //generate a pseudorandom integer from 0 to 1 void ResetRandom(); //reset pseudorandom integer array fRand float ObjFunc(float vx); float DeCode(unsigned * pChrom); void StatPop(POP * pop); void InitPop(); //initialize population void InitReport(); //initial info report unsigned Select(); int Mutation(unsigned chromval); int CrossOver(unsigned * parent1,unsigned * parent2,int popidx); void UpdateGen(); void Report(int gen);
Platform: | Size: 537650 | Author: arkzhu | Hits:

[Mathimatics-Numerical algorithms约瑟夫

Description: #include void main() { int i,j,k,a[31],n=0; for(i=0;i<=30;i++) a[i]=0; k=1; for(i=1;i30) k=1; } a[k++]=1; if(k>30) k=1; //n++; } printf("%d\n",k); for(i=1;i<=30;i++) printf("%d ",a[i]); printf("(1为非*,0为*)"); }
Platform: | Size: 6406 | Author: man001 | Hits:

[Internet-Network一个判断远程主机存活程序代码

Description: 一个判断远程主机存活程序代码(ping) #include #include #include #include #include "winsock.h" #pragma comment(lib,"Ws2_32"); #define SEND_SIZE 32 #define PACKET_SIZE 4096 #define ICMP_ECHO 8 #define ICMP_ECHOREPLY 0 struct icmp { unsigned char icmp_type; unsigned char icmp_code; unsigned short icmp_cksum; unsigned short icmp_id; unsigned short icmp_seq; unsigned long icmp_data; }; struct ip { unsigned char ip_hl:4; unsigned char ip_v:4; unsigned char ip_tos; unsigned short ip_len; unsigned short ip_id; unsigned short ip_off; unsigned char ip_ttl; unsigned char ip_p; unsigned short ip_sum; unsigned long ip_src; unsigned long ip_dst; }; unsigned char sendpacket[PACKET_SIZE]; unsigned char recvpacket[PACKET_SIZE]; struct sockaddr_in dest_addr; struct sockaddr_in from_addr; int sockfd; int pid; unsigned short cal_chksum(unsigned short *addr,int len); int pack(int pack_no); int unpack(unsigned char *buf,int len); void send_packet(void); void recv_packet(void); void main(int argc,char *argv[]) { struct hostent *host; struct protoent *protocol; WSADATA wsaData; int timeout=1000; int SEND_COUNT=4; int i; char *par_host; par_host=argv[argc-1]; //IP赋值 switch(argc) { case 2: break; case 3: if(strcmp(argv[1],"-t")==0) { SEND_COUNT=10000; break; } //fall through default: printf("usage: %s [-t] Host name or IP address\n",argv[0]); exit(1); } if(WSAStartup(0x1010,&wsaData)!=0) { printf("wsastartup error\n"); exit(1); } if( (protocol=getprotobyname("icmp") )==NULL) { printf("getprotobyname error\n"); exit(1); } /* printf("%s\n",protocol->p_name); printf("%s\n",protocol->p_aliases); printf("%d\n",protocol->p_proto); system("pause"); */ if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0) { printf("socket error\n"); exit(1); } if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length); //resolve address to hostname if(host=gethostbyaddr(host->h_addr,4,PF_INET)) par_host=host->h_name; // //printf("%s\n",par_host); // } else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE) { printf("Unkown host %s\n",par_host); exit(1); } pid=getpid(); /* printf("%d\n",pid); system("pause"); */ printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE); for(i=0;i1) { sum+=*w++; nleft-=2; } if( nleft==1) { *(unsigned char *)(&answer)=*(unsigned char *)w; sum+=answer; } sum=(sum>>16)+(sum&0xffff); sum+=(sum>>16); answer=~sum; return answer; } //打包 int pack(int pack_no) { int packsize; struct icmp *icmp; packsize=8+SEND_SIZE; icmp=(struct icmp*)sendpacket; icmp->icmp_type=ICMP_ECHO; icmp->icmp_code=0; icmp->icmp_cksum=0; icmp->icmp_seq=pack_no; icmp->icmp_id=pid; icmp->icmp_data=GetTickCount(); icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/ return packsize; } //解包 int unpack(unsigned char *buf,int len) { struct ip *ip; struct icmp *icmp; double rtt; int iphdrlen; ip=(struct ip *)buf; iphdrlen=ip->ip_hl*4; icmp=(struct icmp *)(buf+iphdrlen); if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) ) { len=len-iphdrlen-8; rtt=GetTickCount()-icmp->icmp_data; printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n", inet_ntoa(from_addr.sin_addr), len, rtt, ip->ip_ttl, icmp->icmp_seq); return 1; } return 0; } //发送 void send_packet() { int packetsize; static int pack_no=0; packetsize=pack(pack_no++); if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0) success=unpack(recvpacket,n); else if (WSAGetLastError() == WSAETIMEDOUT) { printf("Request timed out.\n"); return; } }while(!success); } UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料 TOP
Platform: | Size: 5881 | Author: shuiyuan313 | Hits:

[Crack Hack特殊磁道加密源代码

Description: 使用的是API编程,可格式化、校验和读写特殊扇区。可用作Windows下的磁盘加密。本函数还有以下两个缺点以待改进: 1.本函数还只能读能读 A: 和 B:,即只能对软盘操作 2.不能改变磁盘扇区大小,只能是标准的 512 个字节。 参数说明: command 操作: 0 重置磁盘 2 读扇区 3 写扇区 4 校验磁道 5 格式化磁道 8 得到设备参数 (int 1EH) drive 驱动器 A:=0 B:=1 head 磁头号,范围 0 - 1 track 磁道号,范围 0 - 84 ( 80 - 84 为特殊磁道,通常用来加密 ) sector 扇区号,范围 0 - 255 ( 19 - 255 为非标准扇区编号,通常用来加密) nsectors 每次读或写的扇区数,不能超出每磁道的最大扇区数 buffer 数据写入或读出的缓冲区,大小为 512 个字节 返回值 ( 同 Int 13H ): 0x0 成功 0x1 无效的命令 0x3 磁盘被写保护 0x4 扇区没有找到 0xa 发现坏扇区 0x80 磁盘没有准备好-using the API programming, formatting and testing literacy and special sectors. Windows can be used as a disk encryption. This function has the following two shortcomings to be improved : 1. This function can only be read, read A : and B : that only the right to operate two floppy disks. No change disk sector size, the standard is only 512 bytes. Parameter Description : command operations : 0 Reading 2 replacement disk write Sector Sector 3 4 5 checksum track to be formatted track eight equipment parameters (int 1EH) drive drive A : = 0 B : = 1 head head, range 0-1 track track, the range of 0-84 (80-84 for special track, normally used for encryption) sector sector, the scope of 0-255 (19-255 for a non-standard sector numbers, commonly used encryption) nsectors each read or write in the num
Platform: | Size: 38912 | Author: 李小 | Hits:

[OtherHexStrToInt

Description: 函数 long StrToData(CString strData,int jz) 功能:字符串转为正整数值 [字符串可为2-16]任意进制数值字符串 返回:长整型数值 参数:strData 为将要转换的字符串 参数:jz 为字符串的进制 如: CString s s="FFA6" long data=StrToData(s,16) 则:data的值为:65446 用法:将StrToData.h和StrToData.cpp复制加入到您的工程里,在需要调用的函数中      加入#include "StrToData.h"即可调用 -function long StrToData (CString strData. int jz) function : is the string to integer values [string for 2-16] arbitrary numerical string to 229 : long integer numerical parameters : strData will be converted to a string parameters : jz for the string-band such as : CString s = s "FFA6" long StrToData data = (s, 16) : data values are : 65446 directions : StrToData.cpp StrToData.h and will be added to your copy of the works, in the need to call a function to add# include "StrToData.h" can be transferred with
Platform: | Size: 12288 | Author: 张海良 | Hits:

[assembly languageint

Description: 编写函数int index返回字符t在字条串s中出现的最左边的位置,如果在s中没有与t匹配的子串,不返回-1-function int index prepared to return to the characters not string's note appeared in the leftmost position, If s and t is not matched substring, not to return-1
Platform: | Size: 7168 | Author: luyou | Hits:

[File OperateReadFile

Description: 打开一个TXT文件并显示在EDIT控件中 步骤: 1.新建一个基于对话框的工程,名称为ReadFile 2.在界面上添加一个按钮(IDC_BUTTON1)和一个文本编辑(IDC_EDIT1) IDC_EDIT1的属性:多行、可下拉滚动条. 3.编辑按钮触发事件(void CReadFileDlg::OnButton1()) void CReadFileDlg::OnButton1() { // TODO: Add your control notification handler code here CString sFileFilter="*.hex|*.hex" CString sFileName CFileDialog fDlg(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,sFileFilter,NULL) fDlg.DoModal() sFileName=fDlg.GetFileName() if(sFileName!="") { CFile file(sFileName,CFile::modeRead) int nFileLength=file.GetLength() char *buffer HGLOBAL hgl=::GlobalAlloc(GMEM_MOVEABLE,nFileLength+1) buffer=(char *)::GlobalLock(hgl) file.Read(buffer,nFileLength) SetDlgItemText(IDC_EDIT1,buffer) ::GlobalUnlock(hgl) ::GlobalFree(hgl) } UpdateData(false) } -Open a TXT file and displayed in the EDIT control steps: 1. Create a new dialog-based project, known as the ReadFile2. In the interface to add a button (IDC_BUTTON1) and a text editor (IDC_EDIT1) IDC_EDIT1 properties: multi-line, can be drop-down scroll bar .3. Edit button trigger events (void CReadFileDlg:: OnButton1 ()) void CReadFileDlg:: OnButton1 () (//TODO: Add your control notification handler code here CString sFileFilter =*. hex |*. hex CString sFileName CFileDialog fDlg (true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFileFilter, NULL) fDlg.DoModal () sFileName = fDlg.GetFileName () if (sFileName! =) (CFile file (sFileName, CFile:: modeRead) int nFileLength = file.GetLength () char* buffer HGLOBAL hgl =:: GlobalAlloc (GMEM_MOVEABLE, nFileLength+ 1) buffer = (char*):: GlobalLock (hgl) file.Read (buffer, nFileLength) SetDlgItemText (IDC_EDIT1, buffer):: GlobalUnlock (hgl):: GlobalFree (hgl)) UpdateData (false))
Platform: | Size: 1888256 | Author: 这程子 | Hits:

[assembly language1-2

Description: 二、通过将其元素插入到双向链表中的方法对数组A进行排序。算法对链表的当前操作位置进行维护,当需要插入表项时,若新元素比当前位置值要大,则往前移动;若小则往后移动。编写函数DoubleSort实现上述排序算法。 template <class T> void DoubliSort( T a[], int n) -Second, through its elements inserted into the two-way linked list of methods to sort array A. Algorithm to list the current operating position for maintenance, when the need to insert a table entry, if the new element to the location than the current value to big, then move forward if small is the next move. Prepared to achieve the above function DoubleSort sorting algorithm. template
Platform: | Size: 850944 | Author: zzlbly | Hits:

[Windows Developfloat_char_int_string

Description: 各种基本数据类型转换源程序。 本程序涉及到的数据类型有:float, int , char, string.-A variety of basic data type conversion source. This procedure involves the data types are: float, int, char, string.
Platform: | Size: 107520 | Author: Steno | Hits:

[Crack Hacksha-1

Description: 用SHA算法实现对任意文件的hash摘要,并且把hash摘要值(至少为160bit)存入另一个文件,形如: hash inputfile hashvaluefile 说明:SHA算法的实现至少为160bit,或者可以选择256,384或者512的,可以查阅相关资料,按照标准来实现(hash的算法是否正确,可以和网上的标准算法对比,用相同的输入看是否能够得到相同的输出)控制台编程: int main(int argc, char *argv[ ]) -Programme for SHA-1, include the project and .cpp&.h files.Absolutely available
Platform: | Size: 4096 | Author: Heyyou | Hits:

[assembly language1

Description: 编写一个程序,输出基本数据类型char, short, int, long, float, double和指针类型void *, char *, short *, int *, long *, float *, double *的数据类型的长度。-The preparation of a program, the output of basic data types char, short, int, long, float, double and pointer type void*, char*, short*, int*, long*, float*, double* length of data types.
Platform: | Size: 890880 | Author: bettwe | Hits:

[Windows DevelopVCTest

Description: 这是一个IP地址的分解代码可以将网址分解四个Int数据例如:(192.168.1.2)分解为192 168 1 2-This is an IP address of the decomposition of the code can be broken down 4 Int data such as URL: (192.168.1.2) divided into 19,216,812
Platform: | Size: 7168 | Author: unkx | Hits:

[Mathimatics-Numerical algorithms1

Description: 用一个函数完成对sin cos exp 函数的不同上线积分-float integral(float (*p)(float),float a,float b,int n)
Platform: | Size: 10240 | Author: 杨玉丽 | Hits:

[Other2

Description: 编写筛选查找素数函数: void sieve(bool isPrime[], int n) 其中isPrime[ ]为一个布尔型数组,n为数组大小。由于2是第一个素数, 所以设置isPrime[0]和isPrime[1]的值为false,并设置其余的元素初值为true。 然后对从4到n-1的每一个i,判断i是否能够被2整除,如果i能够被2整除,则设置isPrime[i]为false。 对从2到n/2的每一个可能的数值重复以上处理,当操作结束时,所有值为true的isPrime[i]所对应的i就是素数,它们将是从筛子中掉下来的。-Find prime numbers prepared by screening the function: void sieve (bool isPrime [], int n) which isPrime [] as a Boolean array, n is the size of the array. Because 2 is the first prime number, so set the isPrime [0], and isPrime [1] a value of false, and set the initial value of the remaining elements of true. And then from 4 to n-1 for each i, to determine whether i can be divisible by 2, if i can be divisible by 2, then set the isPrime [i] is false. From 2 to n/2 possible values for each one to repeat the above processing, when the operation ended, all the true value of the isPrime [i] corresponding to i is a prime number, they will be falling from the sieve in the past.
Platform: | Size: 1176576 | Author: 闻悦 | Hits:

[CSharp1

Description: 编写程序通过设置ios::scientific和ios::fixed标志以定点和科学计数法显示浮点类型数据。 测试: #include <iostream> using namespace std int main() { double x = .001234567, y = 1.886e9 //… return 0 } -Write a program by setting the ios:: scientific and ios:: fixed flag with fixed-point and scientific notation floating-point type data display. Test:# include <iostream> using namespace std int main () (double x = .001234567, y = 1.886e9 // ... return 0 )
Platform: | Size: 1428480 | Author: Cheng | Hits:

[Otherlibscl-1.0.2

Description: This a Small Container Library, SCL. If you are not sure what a container is, then ignore the word container in this file and you ll probably understand everything. This library provides hash tables, list, queue, stack, symbol, balanced binary tree, and a vector as abstract data types. Multiple independent instances of the same abstract type can be used, each with its own arbitrary contents. SCL does not redefine the world with SCL_int, SCL_long, etc. The SCL functions use arguments that are standard: long, int, size_t, etc. -This is a Small Container Library, SCL. If you are not sure what a container is, then ignore the word container in this file and you ll probably understand everything. This library provides hash tables, list, queue, stack, symbol, balanced binary tree, and a vector as abstract data types. Multiple independent instances of the same abstract type can be used, each with its own arbitrary contents. SCL does not redefine the world with SCL_int, SCL_long, etc. The SCL functions use arguments that are standard: long, int, size_t, etc.
Platform: | Size: 195584 | Author: GV | Hits:

[Consoleint

Description: 输入一个数字int转换成字符char,程序短小,适合练习!-int to char
Platform: | Size: 247808 | Author: zfgn | Hits:

[VC/MFC1

Description: 最短路劲    假设湖是100×100的正方形,设湖的中心在(0,0),湖的东北角的坐标是(50,50)。湖中心的圆形小岛的圆心在(0,0),直径是15.一些凶猛的鳄鱼分布在湖中不同的位置。现已知湖中鳄鱼的位置和James Band可以跳的最大距离,请你告诉James Band一条最短的到达湖边的路径。他逃出去的路径的长度等于他跳的次数。-     typedef struct GraphNodeRecord{       int X /* x轴坐标*/       int Y /* y轴坐标*/       unsigned int Step /*跳至该点的步数*/       Vertex Path /*记录上一个点*/      } GraphNode      typedef GraphNode*Graph
Platform: | Size: 249856 | Author: 田茵 | Hits:

[Graph programint

Description: 编写函数int index返回字符t在字条串s中出现的最左边的位置,如果在s中没有与t匹配的子串,不返回-1-function int index prepared to return to the characters not string' s note appeared in the leftmost position, If s and t is not matched substring, not to return-1
Platform: | Size: 8192 | Author: intheirtra | Hits:

[Other1

Description: 编写实现C=A+B操作的函数。其中,矩阵A、矩阵B和矩阵C均采用压缩存储方式存储,矩阵元素均为int类型。并设计一个测试主函数,要求按矩阵方式输出矩阵C的数值。设矩阵A和矩阵B为如下所示的矩阵: A=[█(1 2 3@2 4 5@3 5 6)] B=[█(10 20 30@20 40 50@30 50 60)] -Prepared to achieve C = function A+B operation. Among them, the matrix A, the matrix B and C matrices are stored in compressed storage, the matrix elements are of type int. The main function and design a test that requires the matrix output matrix C values. Let matrix A and matrix B is a matrix as follows: A = [█ (1 2 3 @ 2 4 5 @ 3 5 6)] B = [█ (10 20 30 @ 20 40 50 @ 30 50 60)]
Platform: | Size: 4096 | Author: ccyu | Hits:
« 12 3 4 5 6 7 8 9 10 ... 50 »

CodeBus www.codebus.net